package com.example.demo.repository;

import com.example.demo.entity.Expense;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ExpenseRepository extends JpaRepository<Expense,Integer> {

    @Query(value = "select * from expense where user_id = %?1 AND activity_id = %?2;",nativeQuery = true)
    Expense findByUserIdAndActivityId(Integer userid, Integer activityid);

    @Query(value = "select * from expense where user_id = %?1;",nativeQuery = true)
    List<Expense> findByUserId(Integer userId);

    @Query(value = "select * from expense where activity_id in %?1;",nativeQuery = true)
    List<Expense> findByActivityId(List<Integer> collect);
}
